<?php

namespace app\admin\model;

use app\common\model\TimeModel;

class UserAmountLog extends TimeModel {

    protected $name = "user_amount_log";

    protected $deleteTime = "delete_time";


    public function user() {
        return $this->belongsTo('\app\admin\model\User', 'user_id', 'id');
    }


    public function getUserList() {
        return \app\admin\model\User::column('title', 'id');
    }

    /**
     * 添加流水
     * @param $user_id
     * @param $money
     * @param int $type
     * @param int $cointype
     * User : Orange Tel: 181-3414-1353 QQ:1139552211
     * Date    : 2021/6/9 下午12:01
     */
    public function addLog($user_id, $money, $type = 7, $cointype = 6) {
        UserAmountLog::instance()->insert([
            'user_id'     => $user_id,
            'type'        => $type,
            'amount'      => $money,
            'cointype'    => $cointype,
            'create_time' => time()
        ]);
    }

}